package com.ym.student.system.mapper;

import com.ym.student.system.entity.SysMenu;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author self-DIscipline123
 * @since 2025-04-09
 */
public interface SysMenuMapper extends BaseMapper<SysMenu> {


    static List<SysMenu> selectMenusUserById(Integer userId) {
        return null;
    }

    @Select("SELECT m.* FROM sys_menu m " +
                "JOIN sys_role_menu rm ON m.id = rm.menu_id " +
                "JOIN sys_user_role ur ON rm.role_id = ur.role_id " +
                "WHERE ur.user_id = #{userId} " +
                "ORDER BY m.order_num")
        List<SysMenu> selectMenusByUserId(@Param("userId") Long userId);

        @Select("SELECT * FROM sys_menu WHERE parent_id = #{parentId} ORDER BY order_num")
        List<SysMenu> selectByParentId(@Param("parentId") Long parentId);
    }

